/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dbohry
 */
@Entity
@Table(name = "CARRINHO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Carrinho.findAll", query = "SELECT c FROM Carrinho c"),
    @NamedQuery(name = "Carrinho.findByCarrinhoId", query = "SELECT c FROM Carrinho c WHERE c.carrinhoId = :carrinhoId"),
    @NamedQuery(name = "Carrinho.findByFinalizada", query = "SELECT c FROM Carrinho c WHERE c.finalizada = :finalizada")})
public class Carrinho implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CARRINHO_ID")
    private Long carrinhoId;
    @Column(name = "FINALIZADA")
    private Integer finalizada;
    @JoinColumn(name = "USUARIO_USUARIO_ID", referencedColumnName = "USUARIO_ID")
    @ManyToOne
    private Usuario usuarioUsuarioId;
    @JoinColumn(name = "COMPRA_COMPRA_ID", referencedColumnName = "COMPRA_ID")
    @ManyToOne
    private Compra compraCompraId;

    public Carrinho() {
    }

    public Carrinho(Long carrinhoId) {
        this.carrinhoId = carrinhoId;
    }

    public Long getCarrinhoId() {
        return carrinhoId;
    }

    public void setCarrinhoId(Long carrinhoId) {
        this.carrinhoId = carrinhoId;
    }

    public Integer getFinalizada() {
        return finalizada;
    }

    public void setFinalizada(Integer finalizada) {
        this.finalizada = finalizada;
    }

    public Usuario getUsuarioUsuarioId() {
        return usuarioUsuarioId;
    }

    public void setUsuarioUsuarioId(Usuario usuarioUsuarioId) {
        this.usuarioUsuarioId = usuarioUsuarioId;
    }

    public Compra getCompraCompraId() {
        return compraCompraId;
    }

    public void setCompraCompraId(Compra compraCompraId) {
        this.compraCompraId = compraCompraId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (carrinhoId != null ? carrinhoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Carrinho)) {
            return false;
        }
        Carrinho other = (Carrinho) object;
        if ((this.carrinhoId == null && other.carrinhoId != null) || (this.carrinhoId != null && !this.carrinhoId.equals(other.carrinhoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Carrinho[ carrinhoId=" + carrinhoId + " ]";
    }
    
}
